package com.ibeeking.found.common.enums;

/**
 * @Author ibeeking
 * @Date: 2021-01-05 19:15
 * @Description: 时间单位枚举
 */
public enum TimeUnitEnum {
    /**
     * 年
     */
    YEAR(0, "年"),
    MONTH(1, "月"),
    WEEK(2, "周"),
    DAY(3, "日"),
    HOUR(4, "时"),
    MINUTE(5, "分"),
    SECOND(6, "秒"),
    ;
    private Integer code;
    private String lable;

    TimeUnitEnum(int code, String lable) {
        this.code = code;
        this.lable = lable;
    }

    public Integer getCode() {
        return code;
    }

    public String getLable() {
        return lable;
    }

    public static TimeUnitEnum getEnum(Integer code) {
        for (TimeUnitEnum enumObj : values()) {
            if (enumObj.getCode().equals(code)) {
                return enumObj;
            }
        }
        return null;
    }
}
